import LoginSer from './LoginSer'
// import tool from '../../utils/tool'
// let {getmd5} = tool
export default {
  name: 'Login',
  data () {
    return {
      labelPosition: 'right',
      rules: {
        phone: [
          { required: true, message: '请输入账号', trigger: 'blur' },
          { min: 11, max: 11, message: '长度不对', trigger: 'blur' }
        ],
        password: [
          { required: true, message: '请选择活动区域', trigger: 'change' }
        ],
        date1: [
          { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
        ],
        date2: [
          { type: 'date', required: true, message: '请选择时间', trigger: 'change' }
        ],
        type: [
          { type: 'array', required: true, message: '请至少选择一个活动性质', trigger: 'change' }
        ],
        resource: [
          { required: true, message: '请选择活动资源', trigger: 'change' }
        ],
        desc: [
          { required: true, message: '请填写活动形式', trigger: 'blur' }
        ]
      },
      loginInfo: {
        phone: '',
        password: null,
        sex: ''
      },
      options: ['女', '男', '保密']
    }
  },
  methods: { // 添加在data(){...},的后面
    create (formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          let postData = this.loginInfo
          // postData.password = getmd5(this.loginInfo.password)
          LoginSer.Login(postData)
        } else {
          return false
        }
      })
    },
    resetForm (formName) {
      this.$refs[formName].resetFields()
    },
    del (index) {
      this.tabledata.splice(index, 1) // 删除点击的对象，index是lot-scope="a" a.$index传过来的
    }
  }
}
